/**
 * @file      fs.h
 * @copyright Copyright (c) 2020, ZCW Co., Ltd. All Rights Reserved.
 * @brief     brief
 * @author    caiwang213@qq.com
 * @date      2020-06-06 00:25:18
 *
 * @note
 *  file system defines
 *
 * @see
 *  filesytem c++17
 */
#ifndef __FS_H__
#define __FS_H__
#include "idir.h"

namespace log4x
{
class fs
{
public:
    /**
     * @brief       判断指定的文件或目录是否存在
     *
     * @param [in]  path 文件或目录路径
     */
    static bool     exists(const string& path);

    static bool     is_dir(const string& path);
    static int      mk_dir(const string& path);
    static int      ls_dir(const string& path, vector<string>& files);

    static size_t   file_size(const string& path);
    static int      chmod(const string& path, uint32_t mode);

    /**
    * @brief        拷贝文件或目录
    *
    * @note         目录不会覆盖,文件会覆盖
    */
    static int      copy(const string& from, const string& to);
    static bool     remove(const string& path);
    static int      rename(const string& from, const string& to);

    static string&  path_to_win(string& unix_path);
    static string&  path_to_unix(string& win_path);

    static string   basename(const string& fpath);
    static string   shortname(const string& fpath);

    static string   stem(const string& fpath);
    static string   extension(const string& fpath);

    static string   absolute_path(const string& relative_path);
};
}
#endif
